#include "Configuration.h"

Configuration *globalConfigInstance = nullptr;


Configuration &getGlobalConfiguration() {
    if (!globalConfigInstance) {
        globalConfigInstance = &Configuration::getInstance();
    }
    return *globalConfigInstance;
}


Configuration &Configuration::getInstance() {
    static Configuration instance;
    return instance;
}


bool Configuration::loadConfig(const std::string &file_name) {
    config = YAML::LoadFile(file_name);
    if (!config) {
        std::cout << "Failed to open config file: " << file_name << std::endl;
        return false;
    }
    return true;
}


std::string Configuration::getMysqlHost() const {
    return config["mysql"]["host"].as<std::string>();
}

std::string Configuration::getMysqlDataBases() const {
    return config["mysql"]["db"].as<std::string>();
}

std::string Configuration::getMysqlUser() const {
    return config["mysql"]["user"].as<std::string>();
}

std::string Configuration::getMysqlPassword() const {
    return config["mysql"]["passwd"].as<std::string>();
}

std::string Configuration::getS3AK() const {
    return config["s3"]["ak"].as<std::string>();
}

std::string Configuration::getS3SK() const {
    return config["s3"]["sk"].as<std::string>();
}

std::string Configuration::getS3Region() const {
    return config["s3"]["region"].as<std::string>();
}

std::string Configuration::getS3endpoint() const {
    return config["s3"]["endpoint"].as<std::string>();
}

std::string Configuration::getS3BucketName() const {
    return config["s3"]["bucketName"].as<std::string>();
}





